/**
 * Copyright [2019] [LiBo/Alex of copyright liboware@gmail.com ]
 * <p>
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * <p>
 * http://www.apache.org/licenses/LICENSE-2.0
 * <p>
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.hyts.apilog;

import com.hyts.apilog.annotation.ApiLog;
import com.hyts.apilog.bean.AspectjBean;
import com.hyts.apilog.handler.AbstractAspectHandler;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.After;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.stereotype.Component;

/**
 * @project-name:coffice-toolbox
 * @package-name:com.hyts.apilog
 * @author:LiBo/Alex
 * @create-date:2020-04-14 12:05
 * @copyright:libo-alex4java
 * @email:liboware@gmail.com
 * @description:
 */
public class AspectLoggerProcessor extends AbstractAspectHandler {

    /**
     * 操作服务前置
     * @param joinPoint
     */
    @Override
    protected void beforeMethod(JoinPoint joinPoint) {
//        ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
//        HttpServletRequest request = attributes.getRequest();
//        String url = request.getRequestURL().toString();
//        String ip = request.getRemoteAddr();
//        String classMethod = joinPoint.getSignature().getDeclaringTypeName() + "." + joinPoint.getSignature().getName();
//        Object[] args = joinPoint.getArgs();
//        RequestLog requestLog = new RequestLog(url, ip, classMethod, args);
//        logger.info("Request : {}", requestLog);
        System.out.println("测试beforeMethod");
    }
    /**
     * 操作服务后置
     * @param joinPoint
     */
    @Override
        protected void afterMethod(JoinPoint joinPoint) {
        System.out.println("afterMethod");
    }

    /**
     * 操作服务环绕
     * @param joinPoint
     */
    @Override
    protected void aroundMethod(JoinPoint joinPoint) {
        System.out.println("aroundMethod");
    }

    /**
     * 返回结果操作返回
     * @param joinPoint
     */
    @Override
    protected void returnMethod(JoinPoint joinPoint) {
        System.out.println("returnMethod");
    }

    /**
     * 错误操作返回
     * @param joinPoint
     */
    @Override
    protected void errorMethod(JoinPoint joinPoint) {
        System.out.println("errorMethod");
    }
}
